#!/bin/bash

# Vendor2协议API测试脚本

echo "=========================================="
echo "Vendor2协议API测试"
echo "=========================================="
echo ""

# 服务器地址
SERVER="http://localhost:8000"

# 设备IMEI
IMEI="869778076234039"

echo "📡 服务器地址: $SERVER"
echo "📱 设备IMEI: $IMEI"
echo ""

# ========== 测试1: 发送WiFi修改指令 ==========
echo "🔍 测试1: 发送WiFi修改指令"
echo "----------------------------------------"

curl -X POST "$SERVER/api/device/command/send" \
  -H "Content-Type: application/json" \
  -d "{
    \"mac\": \"$IMEI\",
    \"type\": 1,
    \"vendor\": \"vendor2\",
    \"params\": {
      \"hotspot_name\": \"TestWiFi\",
      \"hotspot_password\": \"password123\",
      \"hotspot_whether_hide\": 0,
      \"status\": 1
    }
  }"

echo ""
echo ""

# ========== 测试2: 发送设备重启指令 ==========
echo "🔍 测试2: 发送设备重启指令"
echo "----------------------------------------"

curl -X POST "$SERVER/api/device/command/send" \
  -H "Content-Type: application/json" \
  -d "{
    \"mac\": \"$IMEI\",
    \"type\": 3,
    \"vendor\": \"vendor2\",
    \"params\": {}
  }"

echo ""
echo ""

# ========== 测试3: 发送上报间隔设置 ==========
echo "🔍 测试3: 发送上报间隔设置"
echo "----------------------------------------"

curl -X POST "$SERVER/api/device/command/send" \
  -H "Content-Type: application/json" \
  -d "{
    \"mac\": \"$IMEI\",
    \"type\": 8,
    \"vendor\": \"vendor2\",
    \"params\": {
      \"nextRptTime\": 300000
    }
  }"

echo ""
echo ""

# ========== 测试4: 发送固件下载指令 ==========
echo "🔍 测试4: 发送固件下载指令"
echo "----------------------------------------"

curl -X POST "$SERVER/api/device/command/send" \
  -H "Content-Type: application/json" \
  -d "{
    \"mac\": \"$IMEI\",
    \"type\": 9,
    \"vendor\": \"vendor2\",
    \"params\": {
      \"firmware_url\": \"http://example.com/firmware.bin\"
    }
  }"

echo ""
echo ""

echo "=========================================="
echo "✅ 所有测试完成"
echo "=========================================="

